package logger

import (
	"fmt"
)

//Trace级别的打印信息，输入要打印的内容，会自动换行
func Trace(v ...interface{}) {
	trace := logger[LevelTrace]
	s := fmt.Sprint(v...)
	message := joint(lTrace, s, colorGreen)
	trace.Println(message)
}

//Trace级别的打印信息，第一个参数输入格式,第二个参数输入要打印的内容，类似fmt.Printf
func Tracef(format string, v ...interface{}) {
	trace := logger[LevelTrace]
	s := fmt.Sprintf(format, v...)
	message := joint(lTrace, s, colorGreen)
	trace.Println(message)
}

//Info级别的打印信息，输入要打印的内容，会自动换行
func Info(v ...interface{}) {
	info := logger[LevelInfo]
	s := fmt.Sprint(v...)
	message := joint(lInfo, s, colorBlue)
	info.Println(message)
}

//Infof级别的打印信息，第一个参数输入格式,第二个参数输入要打印的内容，类似fmt.Printf
func Infof(format string, v ...interface{}) {
	info := logger[LevelInfo]
	s := fmt.Sprintf(format, v...)
	message := joint(lInfo, s, colorBlue)
	info.Println(message)
}

//Debug级别的打印信息，输入要打印的内容，会自动换行
func Debug(v ...interface{}) {
	debug := logger[LevelDebug]
	s := fmt.Sprint(v...)
	message := joint(lDebug, s, colorDarkBlue)
	debug.Println(message)
}

//Debug级别的打印信息，第一个参数输入格式,第二个参数输入要打印的内容，类似fmt.Printf
func Debugf(format string, v ...interface{}) {
	debug := logger[LevelDebug]
	s := fmt.Sprintf(format, v...)
	message := joint(lDebug, s, colorDarkBlue)
	debug.Println(message)
}

//Warn级别的打印信息，输入要打印的内容，会自动换行
func Warn(v ...interface{}) {
	warn := logger[LevelWarn]
	s := fmt.Sprint(v...)
	message := joint(lWarn, s, colorYellow)
	warn.Println(message)
}

//Warn级别的打印信息，第一个参数输入格式,第二个参数输入要打印的内容，类似fmt.Printf
func Warnf(format string, v ...interface{}) {
	warn := logger[LevelWarn]
	s := fmt.Sprintf(format, v...)
	message := joint(lWarn, s, colorYellow)
	warn.Println(message)
}

//Error级别的打印信息，输入要打印的内容，会自动换行
func Error(v ...interface{}) {
	e := logger[LevelError]
	s := fmt.Sprint(v...)
	message := joint(lError, s, colorRed)
	e.Println(message)
}

//Errorf级别的打印信息，第一个参数输入格式,第二个参数输入要打印的内容，类似fmt.Printf
func Errorf(format string, v ...interface{}) {
	e := logger[LevelError]
	s := fmt.Sprintf(format, v...)
	message := joint(lError, s, colorRed)
	e.Println(message)
}

//Panic级别的打印信息，输入要打印的内容，会自动换行
// 执行Panic，递归执行每层的defer后中断程序
func Panic(v ...interface{}) {
	p := logger[LevelPanic]
	s := fmt.Sprint(v...)
	message := joint(lPanic, s, colorRed)
	p.Panicln(message)
}

//Panicf级别的打印信息，第一个参数输入格式,第二个参数输入要打印的内容
// 输出错误信息后，执行Panic()，递归执行每层的defer后中断程序
func Panicf(format string, v ...interface{}) {
	p := logger[LevelPanic]
	s := fmt.Sprintf(format, v...)
	message := joint(lPanic, s, colorRed)
	p.Panicln(message)
}

//Fatal级别的打印信息，输入要打印的内容，会自动换行
// 输出错误信息后，直接执行os.exit(1)中断程序
func Fatal(v ...interface{}) {
	falat := logger[LevelFatal]
	s := fmt.Sprint(v...)
	message := joint(lFatal, s, colorPurple)
	falat.Fatalln(message)
}

//Fatal级别的打印信息，第一个参数输入格式,第二个参数输入要打印的内容
// 输出错误信息后，直接执行os.exit(1)中断程序
func Fatalf(format string, v ...interface{}) {
	falat := logger[LevelFatal]
	s := fmt.Sprintf(format, v...)
	message := joint(lFatal, s, colorPurple)
	falat.Fatalln(message)
}

func (l Logger) Trace(v ...interface{}) {
	trace := l.logger[LevelTrace]
	s := fmt.Sprint(v...)
	message := l.joint(lTrace, s, colorGreen)
	trace.Println(message)
}

func (l Logger) Tracef(format string, v ...interface{}) {
	trace := l.logger[LevelTrace]
	s := fmt.Sprintf(format, v...)
	message := l.joint(lTrace, s, colorGreen)
	trace.Println(message)
}

func (l Logger) Info(v ...interface{}) {
	info := l.logger[LevelInfo]
	s := fmt.Sprint(v...)
	message := l.joint(lInfo, s, colorBlue)
	info.Println(message)
}

func (l Logger) Infof(format string, v ...interface{}) {
	info := l.logger[LevelInfo]
	s := fmt.Sprintf(format, v...)
	message := l.joint(lInfo, s, colorBlue)
	info.Println(message)
}

func (l Logger) Debug(v ...interface{}) {
	debug := l.logger[LevelDebug]
	s := fmt.Sprint(v...)
	message := l.joint(lDebug, s, colorDarkBlue)
	debug.Println(message)
}

func (l Logger) Debugf(format string, v ...interface{}) {
	debug := l.logger[LevelDebug]
	s := fmt.Sprintf(format, v...)
	message := l.joint(lDebug, s, colorDarkBlue)
	debug.Println(message)
}

func (l Logger) Warn(v ...interface{}) {
	warn := l.logger[LevelWarn]
	s := fmt.Sprint(v...)
	message := l.joint(lWarn, s, colorYellow)
	warn.Println(message)
}

func (l Logger) Warnf(format string, v ...interface{}) {
	warn := l.logger[LevelWarn]
	s := fmt.Sprintf(format, v...)
	message := l.joint(lWarn, s, colorYellow)
	warn.Println(message)
}

func (l Logger) Error(v ...interface{}) {
	e := l.logger[LevelError]
	s := fmt.Sprint(v...)
	message := l.joint(lError, s, colorRed)
	e.Println(message)
}

func (l Logger) Errorf(format string, v ...interface{}) {
	e := l.logger[LevelError]
	s := fmt.Sprintf(format, v...)
	message := l.joint(lError, s, colorRed)
	e.Println(message)
}

func (l Logger) Panic(v ...interface{}) {
	p := l.logger[LevelPanic]
	s := fmt.Sprint(v...)
	message := l.joint(lPanic, s, colorRed)
	p.Panicln(message)
}

func (l Logger) Panicf(format string, v ...interface{}) {
	p := l.logger[LevelPanic]
	s := fmt.Sprintf(format, v...)
	message := l.joint(lPanic, s, colorRed)
	p.Panicln(message)
}

func (l Logger) Fatal(v ...interface{}) {
	fatal := l.logger[LevelFatal]
	s := fmt.Sprint(v...)
	message := l.joint(lFatal, s, colorPurple)
	fatal.Fatalln(message)
}

func (l Logger) Fatalf(format string, v ...interface{}) {
	fatal := l.logger[LevelFatal]
	s := fmt.Sprintf(format, v...)
	message := l.joint(lFatal, s, colorPurple)
	fatal.Fatalln(message)
}

